@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">提现</div>
                <div class="panel-body">
                	@foreach($banks as $bank)
                	<div class="col-xs-12 banklist1 bg-greentogreen">
		              <div class="banklist2"><span>{{ $bank->bank_name }}</span>
		              	<button type="button" class="close closebtn"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		              </div>
		              <div class="banklist3 text-left"><span rotl="{{ $bank->id }}">{{ substr_replace($bank->card_number,'*********',4,-4) }}</span>
		              	<a href="{{ url('/withdrawals/currentbanck',['bankid'=>$bank->id]) }}"><button type="button" class="btn btn-info btn-xs right">选择</button></a>
		              </div>
		            </div>
		            @endforeach
                    <!-- <div class="col-xs-12 banklist1 bg-greentogreen">
		              <div class="banklist2"><span>建设银行</span>
		              	<button type="button" class="close closebtn"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		              </div>
		              <div class="banklist3 text-left"><span rotl="12">**** **** **** 6899</span>
		              	<a href=""><button type="button" class="btn btn-info btn-xs right">选择</button></a>
		              </div>
		            </div>
		            <div class="col-xs-12 banklist1 bg-greentogreen">
		              <div class="banklist2"><span>中国银行</span>
		              	<button type="button" class="close closebtn"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		              </div>
		              <div class="banklist3 text-left"><span rotl="36">**** **** **** 6589</span>
		              	<a href=""><button type="button" class="btn btn-info btn-xs right">选择</button></a>
		              </div>
		            </div> -->
		            <a href="{{ url('withdrawals/cashing') }}">
		            <div class="col-xs-12 banklist1 bg-greentogreen text-center">
		              <span class="banklist-add">添加银行卡</span>
		            </div>
		            </a>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal -->
	<div class="modal fade" id="Modalclose" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	        <h4 class="modal-title" id="myModalLabel">确定解除绑定？</h4>
	      </div>
	      <div class="modal-body">
	        	卡号:**** **** **** 6589 建设银行
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	        <button type="button" class="btn btn-primary">确认</button>
	      </div>
	    </div>
	  </div>
	</div>
	<script type="text/javascript">
		window.onload=function(){
			var bankid;
			$('.closebtn').click(function(){
				var banktitle=$(this).parent().parent().find('.banklist2').find('span').html(),
					bankbody=$(this).parent().parent().find('.banklist3').find('span').html();
				bankid=$(this).parent().parent().find('.banklist3').find('span').attr('rotl');
				$('#Modalclose').find('.modal-body').html(banktitle+'&nbsp'+bankbody);
				$('#Modalclose').modal('toggle');
			})
			$('.btn-primary').click(function(){
				//alert(bankid);
				$.ajax({
					type:"post",
					data:{'_token':"{{csrf_token()}}",bankid:bankid},
					dataType:'json',
					url:"{{ url('/withdrawals/cashing/deletebank') }}",
					async:true,
					success:function(data){
						if(data['status']==1){
							$('#Modalclose').find('.modal-body').html('解绑成功！');
							window.location.href="{{ url('/withdrawals/banklist') }}";
						}else{
							$('#Modalclose').find('.modal-body').html('解绑失败，如有疑问请联系客服！');
						}
					}
				});
			})
		}
	</script>
</div>
@endsection
